package com.bvr;

import java.util.Calendar;

import com.bvr.CalendarView.OnMonthChangedListener;
import com.bvr.CalendarView.OnSelectedDayChangedListener;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class TempActivity extends Activity {
	private static CalendarView _calendar;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.temp);
		_calendar = (CalendarView) findViewById(R.id.calendar_view);
		_calendar.setOnMonthChangedListener(new OnMonthChangedListener() {
			public void onMonthChanged(CalendarView view) {
				markDays();
			}
		});

		_calendar.setOnSelectedDayChangedListener(new OnSelectedDayChangedListener() {
					public void onSelectedDayChanged(CalendarView view) {
						View[] vs = new View[2];

						TextView tv1 = new TextView(
								TempActivity.this);
						tv1.setText("TODO:");
						vs[0] = tv1;

						TextView tv2 = new TextView(
								TempActivity.this);
						tv2.setText("Put events for this day here.");
						vs[1] = tv2;

						view.setListViewItems(vs);
					}
				});
		markDays();
		 

	}

	private void markDays() {
		// TODO: Find items in the range of _calendar.getVisibleStartDate() and
		// _calendar.getVisibleEndDate().
		// TODO: Create CalendarDayMarker for each item found.
		// TODO: Pass CalendarDayMarker array to
		// _calendar.setDaysWithEvents(markers)

		// _calendar.setDaysWithEvents(new CalendarDayMarker[] { new
		// CalendarDayMarker(Calendar.getInstance(), Color.CYAN) });

		try {
			CalendarDayMarker[] ms = new CalendarDayMarker[5];
			ms[0] = new CalendarDayMarker(2011, 3, 10, Color.BLUE);
			ms[1] = new CalendarDayMarker(2011, 3, 11, Color.DKGRAY);
			ms[2] = new CalendarDayMarker(2011, 3, 12, Color.CYAN);
			ms[3] = new CalendarDayMarker(2011, 3, 13, Color.MAGENTA);
			ms[4] = new CalendarDayMarker(2011, 3, 14, Color.RED);
			_calendar.setDaysWithEvents(ms);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println(e.getMessage());
		}
		
		System.out.println(Calendar.getInstance().toString());
		//updateDisplay();

	}	

}
